#include "../serverPool.h"
int rm_dir(const char *filename)
{
    int ret = 0;
    DIR *dir = opendir(filename);
    ERROR_CHECK(dir, NULL, "打开目录失败");
    struct dirent *entry;
    int is_empty = 1;
    while ((entry = readdir(dir)) != NULL)
    {
        if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
        {
            continue;
        }
        is_empty = 0;
        break;
    }

    if (!is_empty)
    {
        fprintf(stderr, "目录非空，无法删除：%s\n", filename);
        exit(EXIT_FAILURE);
    }
    else
    {
        printf("目录为空，准备删除：%s\n", filename);
        ret = rmdir(filename);
        ERROR_CHECK(ret, -3, "删除目录失败");
    }
    closedir(dir);
    return 0;
}
